$(document).ready(function(){
	$(".most").css("display","none");

	$(".accordion .divParaAcordeon h3:first").addClass("active");
	$(".accordion .divParaAcordeon :not(:first)").hide();

	$(".accordion h3").click(function(){
		$(this).next(".divParaAcordeon").slideToggle("fast")
		.siblings(".divParaAcordeon:visible").slideUp("fast");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});

	$('#cbxSalas').click(function() {
		var selectVal = $('#cbxSalas :selected').val();
		if (selectVal == 'Otra') {
			$(".most").css("display","block");
		}
		else{
			$(".most").css("display","none");
		}
	}); 

	$(function() {
		$(".fecha" ).datepicker({
		},$.datepicker.regional['es']); 
	}); 

	jQuery(function($){
		$.datepicker.regional['es'] = {
				closeText: 'Cerrar',
				prevText: 'Anterior',
				nextText: 'Siguiente',
				currentText: 'Hoy',
				monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
				monthNamesShort: ['Ene','Feb','Mar','Abr', 'May','Jun','Jul','Ago','Sep', 'Oct','Nov','Dic'],
				dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
				dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
				dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
				weekHeader: 'Sm',
				dateFormat: 'dd/mm/yy',
				firstDay: 1,
				numberOfMonths: 1,
				isRTL: false,
				showMonthAfterYear: false,
				yearSuffix: ''};
		$.datepicker.setDefaults($.datepicker.regional['es']);
	});
	$(".fecha").datepicker({
		onSelect: function(dateText) { 
			dateFormat: 'dd/mm/yy'
				// var fecha= $.datepicker.parseDate( "dd-mm-yy", dateText )
				// var fechaFormato= $.datepicker.formatDate("dd-mm-yy",fecha);
				var f= document.getElementById("fecha");
	if(f == null){
		alert("Null")
	}else{
		document.getElementById("fecha").value = dateText;}
		}

	});


	var myControl=  {
			create: function(tp_inst, obj, unit, val, min, max, step){
				$('<input type="text" class="ui-timepicker-input" value="'+val+'" style="width:50%" readonly="true">')
				.appendTo(obj)
				.spinner({
					min: min,
					max: max,
					step: step,
					change: function(e,ui){ // key events
						// don't call if api was used and not key press
						if(e.originalEvent !== undefined)
							tp_inst._onTimeChange();
						tp_inst._onSelectHandler();
					},
					spin: function(e,ui){ // spin events
						tp_inst.control.value(tp_inst, obj, unit, ui.value);
						tp_inst._onTimeChange();
						tp_inst._onSelectHandler();
					}
				});
				return obj;
			},
			options: function(tp_inst, obj, unit, opts, val){
				if(typeof(opts) == 'string' && val !== undefined)
					return obj.find('.ui-timepicker-input').spinner(opts, val);
				return obj.find('.ui-timepicker-input').spinner(opts);
			},
			value: function(tp_inst, obj, unit, val){
				if(val !== undefined)
					return obj.find('.ui-timepicker-input').spinner('value', val);
				return obj.find('.ui-timepicker-input').spinner('value');
			}
	};


	$(function() {
		$('.hora').timepicker({  
			controlType: myControl	 
		});
	});

	$('.hora').click(function(){
		$('#ui-datepicker-div').css({height:'110px'}) }); 
	
	$('#fecha').click(function(){
		$('#ui-datepicker-div').css({height:'190px'}) }); 
	
	$.timepicker.regional['es'] = {
			timeOnlyTitle: 'Seleccione la hora que desea',
			timeText: 'Hora',
			hourText: 'Hora',
			minuteText: 'Minutos',
			secondText: 'Segundos',
			currentText: 'Hora actual',
			closeText: 'Aceptar',
			timeFormat: 'HH:mm',
			isRTL: false
	};
	$.timepicker.setDefaults($.timepicker.regional['es']);


});
